package com.meilai.project.mapper.system;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.meilai.project.dto.system.MessageCenterSearchDTO;
import com.meilai.project.entity.system.MessageCenter;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author 张驰
 * @since 2022-04-15
 */
@Mapper
public interface MessageCenterMapper extends BaseMapper<MessageCenter> {
    List<MessageCenter> selectPageList(Page<MessageCenter> page, @Param("searchDTO") MessageCenterSearchDTO searchDTO);

    @Select("select COUNT(1) from message_center where user_id=#{user_id} and read_at IS NULL")
    Integer getOwnUnReadCount(@Param("user_id") Long user_id);
}
